package com.dailyblue.java.spring.ioc.annotation;

import com.DemoA;
import com.dailyblue.java.spring.ioc.annotation.pojo.Person;
import com.dailyblue.java.spring.ioc.annotation.pojo.Score;
import com.dailyblue.java.spring.ioc.annotation.pojo.Student;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class App {

    private static ApplicationContext beans ;

    static {
        beans = new AnnotationConfigApplicationContext("com.dailyblue.java.spring.ioc.annotation");
    }

    private static void a(){
        Student student = beans.getBean("student",Student.class);
        System.out.println(student);
    }

    private static void b(){
        System.out.println("-------------------------------->");
        Score score1 = beans.getBean(Score.class);
        Score score2 = beans.getBean(Score.class);
        System.out.println(score1);
        System.out.println(score2);
    }

    private static void c(){
        System.out.println("开始调用c方法");
        Person person = beans.getBean(Person.class);
        System.out.println("获取到了Person类的对象");
        System.out.println(person);
        person.show();
    }

    private static void d(){
        DemoA da = beans.getBean(DemoA.class);
        da.a();
    }
    public static void main(String[] args) {
        d();
    }
}
